<!--
* description: 采购管理-出库单查询
* author: hzm
* createdDate: 2021-1-21
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-is-fix-choose="false"
      :dynamic-is-fix-index="false"
      :dynamic-api-style="'restful'"
      :dynamic-is-show-more-btn="true"
    />
    <!-- <detail
      :key="editPopupsKey"
      :dynamic-edit-row-data="editRowData"
      :popups-visible="editPopupsVisible"
      :dynamic-api-style="'restful'"
      @close="close"
    /> -->
  </div>
</template>

<script>
// import { formMixins } from "@/components/mixins/formMixins";
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins"
import OneTableTemplate from "@/components/templates/oneTable"
import { orgApis } from "@/api/paSparePartsManagement"
import { exportExcel } from '@/utils/getTimeString.js'

export default {
  name: "outOfWarehouseList",
  components: {
    OneTableTemplate,
    // Detail: () => import('./detail')
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      dynamicApiConfigs: orgApis.findOutBoundStoreQueryPage,
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "dlrCode",
                label: "网点编码",
                align: "center",
              },
              {
                prop: "dlrShortName",
                label: "网点名称",
                align: "center",
              },
              {
                prop: "purOrderCode",
                label: "订单号",
                align: "center",
              },
              {
                prop: "purOrderTypeCn",
                label: "订单类型",
                align: "center",
              },
              {
                prop: "outStorageCode",
                label: "出库单号",
                align: "center",
              },
              {
                prop: "createdDate",
                label: "出库日期",
                align: "center",
              },
              {
                prop: "partNo",
                label: "备件编码",
                align: "center",
              },
              {
                prop: "partName",
                label: "备件名称",
                align: "center",
              },
              {
                prop: "unit",
                label: "单位",
                align: "center",
              },
              {
                prop: "outQty",
                label: "出库数量",
                align: "center",
              },
              {
                prop: "purPrice",
                label: "出库单价",
                align: "center",
              },
               {
                prop: "outPrice",
                label: "出库金额",
                align: "center",
              },
               {
                prop: "warehouseName",
                label: "发货仓库",
                align: "center",
              }
            ],
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              // 库存状态
              {
                compKey: "compKey1",
                labelName: "订单号：",
                codeField: "purOrderCode",
                lookuptype: "VE0212",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
              },
              // 车辆状态
              {
                compKey: "compKey2",
                labelName: "订单类型：",
                codeField: "purOrderType",
                customObj: {
                  api: orgApis.queryOrderTypeList,
                },
                component: () => import("@/components/org/commonSelect"),
                type: "dropdownList",
                isMust: true,
                span: 6,
              },
              // 入库仓库
              {
                compKey: "compKey3",
                labelName: "出库单号：",
                codeField: "outStorageCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
              },
              // 审核状态
              // {
              //   compKey: "compKey4",
              //   labelName: "出库类型：",
              //   codeField: "assignState",
              //   component: () => import("@/components/org/userSeleapiConfig"),
              //   type: "inputText",
              //   isMust: true,
              //   span: 6,
              // },
              // VIN码
              {
                compKey: "compKey5",
                labelName: "网点编码：",
                codeField: "dlrCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
                span: 6,
                isShow:true,
                disabled: true
              },
              // 质量状态
              // {
              //   compKey: "compKey6",
              //   labelName: "供应商编码：",
              //   codeField: "supplierCode",
              //   component: () => import("@/components/org/commonInput"),
              //   type: "inputText",
              //   isMust: false,
              //   span: 6,
              // },
              {
                compKey: "compKey6",
                labelName: "供应商编码：",
                codeField: "supplierCode",
                textField: 'supplierShortName',
                component: () => import('@/components/ve/multipleSearchInput'),
                type: "inputText",
                isMust: false,
                dataToObject: {
                // 控制弹窗页面 搜索 网格 元素
                tableComponents: [
                  {
                    compKey: 'compKey1',
                    labelName: '供应商编码：',
                    codeField: 'supplierCode',
                    component: () => import('@/components/org/commonInput'),
                    type: 'inputText',
                    isMust: true,
                    span: 8
                  },
                  {
                    compKey: 'compKey2',
                    labelName: '供应商简称：',
                    codeField: 'supplierShortName',
                    component: () => import('@/components/org/commonInput'),
                    type: 'inputText',
                    isMust: true,
                    span: 8
                  },
                  {
                    compKey: 'compKey3',
                    labelName: '状态：',
                    codeField: 'isEnable',
                    component: () => import('@/components/org/LookupValue'),
                    oFields: 'statusId,statusText',
                    options: [
                      { statusId: '1', statusText: '启用' },
                      { statusId: '0', statusText: '禁用' }
                    ],
                    type: 'dropdownList',
                    isMust: true,
                    span: 8
                  }
                ],
                formField: {
                  supplierCode: "",
                  supplierShortName: "",
                  isEnable: "",
                },
                tableCols: [
                  {
                    prop: 'supplierCode',
                    label: '供应商编码'
                  },
                  {
                    prop: 'supplierShortName',
                    label: '供应商简称'
                  },
                  {
                    prop: 'supplierFullName',
                    label: '供应商全称'
                  },
                  {
                    prop: 'supplierAddr',
                    label: '详细地址'
                  },
                  {
                    prop: 'linkMan',
                    label: '联系人'
                  },
                  {
                    prop: 'linkManTel',
                    label: '联系电话'
                  },
                  {
                    prop: 'isEnableCn',
                    label: '状态'
                  },
                  {
                    prop: 'remark',
                    label: '备注'
                  }
                ],
                returnField: {
                  prop: 'supplierCode',
                  label: '供应商编码'
                },
                api: orgApis.supplierInformationQueryquery
              },
                span: 6,
              },
              {
                compKey: "compKey7",
                labelName: "出库日期：",
                codeField: "startDate,endDate",
                component: () =>
                  import("@/components/org/datePicker/andtDatePicker"),
                type:'YYYY-MM-DD',
                format: 'yyyy-MM-dd',
                dateOptionsType: '0',
                isMust: false,
                span: 6,
              },
              // 车辆类型
              {
                compKey: "compKey8",
                labelName: "备货仓库：",
                codeField: "warehouseId",
                textField: 'warehouseName',
                customObj: {
                  api: orgApis.queryWareHouseName,
                  defOptionFields:['warehouseId','warehouseName']
                },
                component: () => import("@/components/org/commonSelect"),
                type: "dropdownList",
                isMust: false,
                span: 6,
              },
            ],
      tableButtons: [
        {
          conmpKey: "btenKey1",
          type: "primary",
          size: "small",
          text: "查询",
          name: 'search',
          clickEvent: () => this.queryTable(1),
          position: "right",
        },
        {
          conmpKey: 'btenKey3',
          type: '',
          size: 'small',
          clickEvent: () => this.export(),
          text: this.$t('sys.button.export'),
          name: 'export',
          position: 'right' // 导出
        },
        {
          conmpKey: "btenKey2",
          type: "",
          size: "small",
          text: "重置",
          name: 'reset',
          clickEvent: () => this.reset(),
          position: "right",
        },
      ],
      formField: this.$utils.getFormField(this, {
        purOrderCode: "",
        purOrderType: "",
        outStorageCode: "",
        dlrCode: "",
        supplierCode: "",
        createdDate: "",
        hostLimitState: "",
        warehouseName:"",
        warehouseId: "",
        startDate: "",
        endDate: ""
      }),
    };
  },
  methods: {
    export(){
      exportExcel(this.formField, orgApis.exportOutBoundStoreQuery.APIUrl, orgApis.exportOutBoundStoreQuery.ServiceCode, '出库单查询')
    },
  },
  mounted() {
    // 网点则显示当前网点  禁用  总部去掉
    if(this.$store.getters.orgInfo.DLR_ID === "HOST"){//总部
      this.tableComponents.find(o=>o.codeField==="dlrCode").isShow = false
    } else {
      this.formField.dlrCode = this.$store.getters.orgInfo.DLR_CODE
    }
    this.queryTable(1)
    // this.$refs.multipleTable.list = [{
    //   index: 1
    // }]
  },
};
</script>

<style>
</style>
